#!/usr/bin/env python3
#  
# 1. 定义 Spark 的基本结构信息
# 

from requests import api

class Spark:
    URI         = 'http://zunyun01.store.deepinos.org.cn/store/'
    URI_PACKAGE = 'http://zunyun01.store.deepinos.org.cn/store/Packages'

    KEY_Package          = 'Package'
    KEY_Architecture     = 'Architecture'
    KEY_Version          = 'Version'
    KEY_Priority         = 'Priority'
    KEY_Section          = 'Section'
    KEY_Maintainer       = 'Maintainer'
    KEY_Homepage         = 'Homepage'
    KEY_InstalledSize    = 'Installed-Size'
    KEY_PreDepends       = 'Pre-Depends'
    KEY_Depends          = 'Depends'
    KEY_Recommends       = 'Recommends'
    KEY_Replaces         = 'Replaces'
    KEY_Filename         = 'Filename'
    KEY_Size             = 'Size'
    KEY_MD5sum           = 'MD5sum'
    KEY_SHA1             = 'SHA1'
    KEY_SHA256           = 'SHA256'
    KEY_SHA512           = 'SHA512'
    KEY_Description      = 'Description'
    KEY_LongDescription  = 'LongDescription'

    KEYS = [KEY_Package, KEY_Architecture, KEY_Version, KEY_Priority, KEY_Section, KEY_Maintainer, KEY_Homepage, KEY_InstalledSize, KEY_PreDepends, KEY_Depends, KEY_Recommends, KEY_Replaces, KEY_Filename, KEY_Size, KEY_MD5sum, KEY_SHA1, KEY_SHA256, KEY_SHA512, KEY_Description]

    @staticmethod
    def getSparkPackages() -> str:
        resp = api.get(Spark.URI_PACKAGE)
        return resp.content.decode("utf-8", 'ignore')

    @staticmethod
    def getSparkPackagesSplits() -> list:
        return Spark.getSparkPackages().split('\n\n')
